package shiliu;

/**
 * Created by mc on 2016/8/5.
 */
import java.sql.*;
import static java.lang.System.out;
public class lianxi
{
    public static void main(String[] arges)throws ClassNotFoundException
    {
        Class.forName("com.mysql.jdbc.Driver");
        String jdbcUrl = "jdbc:mysql://localhost:3306/demo";
        String user = "root";
        String passwd = "openhome";
        try(Connection coon = DriverManager.getConnection(jdbcUrl, user, passwd)){
            out.printf("已经%s数据库联机%n",coon.isClosed() ? "关闭":"开启");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
